package com.nervenets.utils;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

public class ReflectionUtil {
    public static List<Field> getFieldInfo(List<Field> fields, Class<?> clazz) {
        if (fields == null) {
            fields = new ArrayList<Field>();
        }
        List<Field> tempFields = new ArrayList<Field>();
        if (clazz != null)
            for (Field fi : clazz.getDeclaredFields()) {
                if (!Modifier.isStatic(fi.getModifiers()))
                    tempFields.add(fi);
            }
        fields.addAll(tempFields);
        if (clazz.getSuperclass() != null) {
            getFieldInfo(fields, clazz.getSuperclass());
        }
        return fields;
    }
}
